<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>测试省市</title>
		<script src="/Public/bootstrap/js/jquery.min.js"></script>
	</head>
	<body>
		<span id="sheng_box"></span>
		<span id="shi_box"></span>
		<span id="qu_box"></span>
	</body>
	
	<script>
		$(function(){
			$.post('/index.php/Home/Api/getList_ssq',{pid:0},function(obj){
				var html = getSelectHtml(obj.d,'sheng','sheng');
				$('#sheng_box').html(html);
				$('#sheng').change(function(){
					var pid = $(this).val();
					$.post('/index.php/Home/Api/getList_ssq',{pid:pid},function(obj){
						var html = getSelectHtml(obj.d,'shi','shi');
						$('#shi_box').html(html);
						$('#shi').change(function(){
							var pid = $(this).val();
							$.post('/index.php/Home/Api/getList_ssq',{pid:pid},function(obj){
								var html = getSelectHtml(obj.d,'qu','qu');
								$('#qu_box').html(html);
							},'json');
						});
					},'json');
				});
			},'json');
			
		});
		
		function getSelectHtml(data,id,name){
			var html = '<select id="'+id+'" name="'+name+'"><option value="">===请选择==</option>';
			$.each(data,function(i,d){
				html += '<option value="'+d.id+'">'+d.title+'</option>';
			});
			html += '</select>';	
			return html;
		}
	</script>
</html>